package com.blockmeta.bbs.baselibrary.widget;

import android.content.Context;
import com.google.android.material.tabs.TabLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by AirThor
 * Date 2018/3/21.
 * 在我的收藏等有编辑的界面里 处于编辑状态时 tab不能点击
 */

public class ToggleTabLayout extends TabLayout {
    private boolean noClick=false;

    public void setNoClick(boolean noClick) {
        this.noClick = noClick;
    }

    public ToggleTabLayout(Context context) {
        super(context);
    }

    public ToggleTabLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ToggleTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return noClick||super.onInterceptTouchEvent(ev);
    }
}
